解题思路:
第一处:使用for循环计算公式,必须计算到m,所以应改为for(i=2; i<=m; i++)。
第二处:在除法运算中,如果除数和被除数都是整数,所么所除结果也是整数,因此应改
为y-=1./(i*i)。
***************************************************
m个人的成绩存放在score数组中,请编写函数fun,它的功能是:将低于平均分的人数作为函数值返回,将低于平均分的分数放在below所指的数组中。
例如,当score数组中的数据为:10、20、30、40、50、60、70、80、90时,函数返回的人数应该是4, below中的数据应为: 10、20、30、40。
注意: 部分源程序在文件PROG1.C文件中。
请勿改动主函数main和其它函数中的任何内容,仅在函数fun的花括号中填入你编写的若干语句。
给定源程序:
#include
#include
int fun(int score[], int m, int below[])
{
}
main( )
{ int i, n, below[9] ;
int score[9] = {10, 20, 30, 40, 50, 60, 70, 80, 90} ;
n = fun(score, 9, below) ;
printf( "\nBelow the average score are: " ) ;
for (i = 0 ; i < n ; i++) printf("%d ", below[i]) ;
NONO() ;
}